package com.railway.bean;

import java.util.List;

public class Page<T> {

	
	private List<T> data ; //代表真实查到的数据
	
	private int pageNum;// 页码
	
	private int pageSize;// 页大小(每一条有多少条数据)
	
	private int totalRows;// 查询的总的条数
	
	private int totalPageNum;// 总页码数
	
	private boolean hasPrev;// 有没有上一页
	
	private boolean hasNext;// 有没有下一页

	public List<T> getData() {
		return data;
	}

	public void setData(List<T> data) {
		this.data = data;
	}

	public int getPageNum() {
		return pageNum;
	}

	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getTotalRows() {
		return totalRows;
	}

	public void setTotalRows(int totalRows) {
		this.totalRows = totalRows;
	}

	public int getTotalPageNum() {
		return totalPageNum;
	}

	public void setTotalPageNum(int totalPageNum) {
		this.totalPageNum = totalPageNum;
	}

	public boolean isHasPrev() {
		return hasPrev;
	}

	public void setHasPrev(boolean hasPrev) {
		this.hasPrev = hasPrev;
	}

	public boolean isHasNext() {
		return hasNext;
	}

	public void setHasNext(boolean hasNext) {
		this.hasNext = hasNext;
	}

	public Page() {
		super();
		// TODO Auto-generated constructor stub
	}

	public Page(List<T> data, int pageNum, int pageSize, int totalRows) {
		super();
		this.data = data;
		this.pageNum = pageNum <=0 ? 1:  pageNum;
		this.pageSize = pageSize <=0 ? 5: pageSize;
		this.totalRows = totalRows;
		this.totalPageNum = totalRows % pageSize == 0 ? totalRows/pageSize : (totalRows/pageSize)+1;
		this.hasNext = pageNum >= totalPageNum ? false:true;
		this.hasPrev = pageNum <= 1 ? false:true;
	}

	@Override
	public String toString() {
		return "Page [data=" + data + ", pageNum=" + pageNum + ", pageSize=" + pageSize + ", totalRows=" + totalRows
				+ ", totalPageNum=" + totalPageNum + ", hasPrev=" + hasPrev + ", hasNext=" + hasNext + "]";
	}
	
	
	
}
